<template>
  <div class="page-header-index-wide">
    <a-row :gutter="24">
      <a-col :span="24" :style="{ marginBottom: '12px' }">
        <a-card :bordered="false" title="子系统">
          <a-col :sm="24" :md="12" :xl="3" :style="{ marginBottom: '24px' }">
            <a-card title="综合管理" :headStyle="headStyle" :bodyStyle="bodyStyle"
                    style="background: #49A4EA; border-radius: 8px" :bordered="false" hoverable>
              <div class="bg-tc" style="display: flex; align-items: center; justify-content: space-between">
                <div class="num"></div>
                <div class="icon">
                  <a-icon type="slack" :style="{fontSize: '40px', color: '#fff'}"/>
                </div>
              </div>
            </a-card>
          </a-col>

          <a-col :sm="24" :md="12" :xl="3" :style="{ marginBottom: '24px' }">
            <a-card title="经营管理" :headStyle="headStyle" :bodyStyle="bodyStyle"
                    style="background: #8693F3; border-radius: 8px" :bordered="false" hoverable>
              <div class="bg-tc" style="display: flex; align-items: center; justify-content: space-between">
                <div class="num"></div>
                <div class="icon">
                  <a-icon type="layout" :style="{fontSize: '40px', color: '#fff'}"/>
                </div>
              </div>
            </a-card>
          </a-col>

          <a-col :sm="24" :md="12" :xl="3" :style="{ marginBottom: '24px' }">
            <a-card title="财务" :headStyle="headStyle" :bodyStyle="bodyStyle"
                    style="background: #5484FF; border-radius: 8px" :bordered="false" hoverable>
              <div class="bg-tc" style="display: flex; align-items: center; justify-content: space-between">
                <div class="num"></div>
                <div class="icon">
                  <a-icon type="account-book" :style="{fontSize: '40px', color: '#fff'}"/>
                </div>
              </div>
            </a-card>
          </a-col>

          <a-col :sm="24" :md="12" :xl="3" :style="{ marginBottom: '24px' }">
            <a-card @click="skip()" title="环保管家" :headStyle="headStyle" :bodyStyle="bodyStyle"
                    style="background: #70B603; border-radius: 8px" :bordered="false" hoverable>
              <div class="bg-tc" style="display: flex; align-items: center; justify-content: space-between">
                <div class="num"></div>
                <div class="icon">
                  <a-icon type="cloud" :style="{fontSize: '40px', color: '#fff'}"/>
                </div>
              </div>
            </a-card>
          </a-col>

        </a-card>
      </a-col>
    </a-row>
    <a-row :gutter="24">
      <a-col :span="24" :style="{ marginBottom: '12px' }">
        <FastMenu/>
      </a-col>
    </a-row>
    <a-row :gutter="24">
      <a-col :sm="24" :md="12" :xl="12" :style="{ marginBottom: '12px' }">
      </a-col>
      <a-col :sm="24" :md="12" :xl="12" :style="{ marginBottom: '12px' }">
      </a-col>
    </a-row>
    <a-row :gutter="48" :style="{ marginBottom: '12px' }">
      <a-col :sm="24" :md="12" :xl="6" :style="{ padding: '0 12px' }">
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ padding: '0 12px' }">
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ padding: '0 12px' }">
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ padding: '0 12px' }">
      </a-col>
    </a-row>
    <a-row :gutter="24">
      <a-col :sm="24" :md="12" :xl="12">
      </a-col>
      <a-col :sm="24" :md="12" :xl="6">
      </a-col>
      <a-col :sm="24" :md="12" :xl="6">
      </a-col>
    </a-row>
    <select-park-modal :sign="2" ref="selectPark" modal-width="1400px" :multi="false" @gain="gain"></select-park-modal>
  </div>

</template>

<script>
import ChartCard from '@/components/ChartCard'
import ACol from 'ant-design-vue/es/grid/Col'
import ATooltip from 'ant-design-vue/es/tooltip/Tooltip'
import MiniArea from '@/components/chart/MiniArea'
import MiniBar from '@/components/chart/MiniBar'
import MiniProgress from '@/components/chart/MiniProgress'
import RankList from '@/components/chart/RankList'
import Bar from '@/components/chart/Bar'
import Bars from '@/components/chart/Bars'
import LineChartMultid from '@/components/chart/LineChartMultid'
import HeadInfo from '@/components/tools/HeadInfo.vue'
import Histogram from '@/components/chart/Histogram'
import Trend from '@/components/Trend'
import { getLoginfo, getVisitInfo } from '@/api/api'
import { getAction } from '@/api/manage'
import FastMenu from './FastMenu'
import Pie from '@/components/chart/Pie'
import SelectParkModal from '@/views/components/modal/SelectParkModal'

const rankList = []
for (let i = 0; i < 7; i++) {
  rankList.push({
    name: '白鹭岛 ' + (i + 1) + ' 号店',
    total: 1234.56 - i * 100
  })
}
const barData = []
for (let i = 0; i < 12; i += 1) {
  barData.push({
    x: `${i + 1}月`,
    y: Math.floor(Math.random() * 1000) + 200
  })
}
export default {
  name: 'IndexChart',
  components: {
    FastMenu,
    ATooltip,
    ACol,
    ChartCard,
    MiniArea,
    MiniBar,
    MiniProgress,
    RankList,
    Bar,
    Trend,
    LineChartMultid,
    HeadInfo,
    Pie,
    Bars,
    Histogram,
    SelectParkModal
  },
  data() {
    return {
      headStyle: {
        borderBottom: 'none',
        color: '#ffff'
      },
      bodyStyle: {
        padding: '5px 24px'
      },
      model: {},
      loading: true,
      center: null,
      rankList,
      barData,
      loginfo: {},
      visitFields: ['ip', 'visit'],
      visitInfo: [],
      url: {
        checkUserOperation: '/api/hmhb/analysis/home/page/checkUserOperation',
      },
      sensorAlarm: {
        processAlarm: {
          alarmCount: 0,
          handled: 0,
          untreated: 0
        },
        gasAlarm: {
          alarmCount: 0,
          handled: 0,
          untreated: 0
        }
      },
      dangerRecordCount: {},
      epiRecordCount: {},
      snapshotCount: {},
      hazardChart: [],
      zoningCount: [],
      pointCount: [],
      data: {},
      studyCount: [],
      sourceData: [],
      fields: []
    }
  },
  created() {
    setTimeout(() => {
      this.loading = !this.loading
    }, 1000)
    this.initLogInfo()
  },
  methods: {
    //跳转
    skip() {
      getAction(this.url.checkUserOperation).then(res => {
        if (res.success && res.result) {
          this.$refs.selectPark.open();
        } else {

        }
      })
    },
    //获取园区id
    gain(data) {
      console.log(data, '园区id')
    },
    initLogInfo() {
      getLoginfo(null).then(res => {
        if (res.success) {
          Object.keys(res.result).forEach(key => {
            res.result[key] = res.result[key] + ''
          })
          this.loginfo = res.result
        }
      })
      getVisitInfo().then(res => {
        if (res.success) {
          this.visitInfo = res.result
        }
      })
    },
  }
}
</script>

<style lang="less" scoped>
.circle-cust {
  position: relative;
  top: 28px;
  left: -100%;
}

.extra-wrapper {
  line-height: 55px;
  padding-right: 24px;

  .extra-item {
    display: inline-block;
    margin-right: 24px;

    a {
      margin-left: 24px;
    }
  }
}

/* 首页访问量统计 */
.head-info {
  position: relative;
  text-align: left;
  padding: 0 32px 0 0;
  min-width: 125px;

  &.center {
    text-align: center;
    /*padding: 0 32px;*/
  }

  span {
    color: rgba(0, 0, 0, 0.45);
    display: inline-block;
    font-size: 0.95rem;
    line-height: 42px;
    margin-bottom: 4px;
  }

  p {
    line-height: 42px;
    margin: 0;

    a {
      font-weight: 600;
      font-size: 1rem;
    }
  }

  .bg-tc {
    display: flex;
    margin-bottom: 20px;

    .num {
      color: #fff;
      font-size: 20px;
    }
  }
}
</style>
